<!--
  #%L
  thinkbig-ui-feed-manager
  %%
  Copyright (C) 2017 ThinkBig Analytics
  %%
  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at
  
      http://www.apache.org/licenses/LICENSE-2.0
  
  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
  #L%
  -->
<div layout="row" layout-align="center start">

    <card-layout body-css="md-padding" style="max-width:980px;width:980px;" flex="initial">

        <header-section>
        <div layout="row" layout-align="space-between-center" flex>
            <div class="card-title" flex>选择模板</div><h2 class="card-sub-header">1 of 5</h2>
        </div>
    </header-section >

    <body-section>
        <md-input-container>
            <label>模板</label>
            <md-select ng-model="vm.nifiTemplateId" ng-disabled="vm.templateSelectionDisabled" ng-change="vm.changeTemplate()">
                <md-option test="test" ng-repeat="template in vm.templates | orderBy:'name'" value="{{template.id}}">
                    {{template.name}}
                </md-option>
            </md-select>
        </md-input-container>
        <div class="error md-caption layout-padding" ng-if="vm.errorMessage != null && !vm.isValid">{{vm.errorMessage}}</div>

        <div layout="column" ng-if="!vm.model.reusableTemplate">
            <md-subheader class="md-subhead left-aligned">管道目标表选项</md-subheader>
            <md-input-container class="md-block layout-padding-top-bottom flex-gt-sm condensed" flex-gt-sm="">
                <md-radio-group ng-model="vm.model.templateTableOption" flex layout="row" ng-change="vm.onTableOptionChange()" required="true">
                    <md-radio-button ng-repeat="tableOption in vm.templateTableOptions" value="{{tableOption.type}}" flex="30">
                        {{tableOption.displayName}}
                        <div class="hint">{{tableOption.description}}</div>
                    </md-radio-button>
                </md-radio-group>
            </md-input-container>
        </div>

        <br/><br/><br/>
        <thinkbig-step-buttons can-continue="vm.isValid && !vm.model.loading" step-index="{{::vm.stepIndex}}"></thinkbig-step-buttons>
    </body-section>

</card-layout>

    <card-layout offsetleftfromprevious top="8" card-css="layout-fill" body-css="md-padding"
                 style="max-width:250px;width:250px;min-width:250px;" flex="initial">
        <header-section>
            <div class="card-title">模板</div>
            <div layout="column" class="layout-padding-top-bottom">
            <span class="item-title" ng-if="!vm.model.loading">
                 <ng-md-icon icon="{{vm.model.icon.title}}" size="20" hide-xs ng-style="{'fill':vm.model.icon.color}" ng-if="vm.model.icon && vm.model.state != 'NOT REGISTERED'">
                 </ng-md-icon>
                {{vm.model.templateName}}</span>
            </div>
        </header-section>

        <body-section>
            <div layout="column" class="layout-padding-top" ng-if="vm.model.loading">
                加载模板 ...
            </div>
            <div layout="column" class="layout-padding-top" ng-if="!vm.model.loading">
                <md-button ng-if="vm.model.state == 'ENABLED' && vm.allowAdmin" ng-disabled="vm.disabling" ng-click="vm.disableTemplate()" class="border-btn">
                    禁用模板
                </md-button>
                <md-button ng-if="vm.model.state == 'DISABLED' && vm.allowAdmin" ng-disabled="vm.enabling" ng-click="vm.enableTemplate()" class="border-btn">
                    启用模板
                </md-button>
                <md-button ng-if="vm.model.state == 'DISABLED' && vm.allowAdmin && vm.model.feedsCount ==0" ng-click="vm.confirmDeleteTemplate()" class="border-btn-warn">
                    删除模板
                </md-button>
                <md-progress-linear md-mode="indeterminate" ng-if="vm.enabling || vm.disabling"></md-progress-linear>
                <div layout="column" class="layout-padding-top-bottom" >
                    <span class="hint">状态</span>
                <span ng-class="{'enabled':vm.model.state == 'ENABLED','disabled':vm.model.state != 'ENABLED'}">
                    <ng-md-icon icon="{{vm.model.stateIcon}}" size="20" ng-if="vm.model.state != 'NOT REGISTERED'"></ng-md-icon> {{vm.model.state}}</span>

                </div>

                <div layout="column" class="layout-padding-top-bottom">
                                    <span class="hint">
                                            最近更新时间
                                           </span>
                    <span>{{vm.model.updateDate | date: 'yyyy-MM-dd hh:mm:ss'}}</span>

                </div>
                <div layout="column" class="layout-padding-top-bottom">
                    <span class="hint">管道</span>
                    <span>  {{vm.model.feedsCount}}</span>

                </div>

                <div layout="column" class="item-column md-list-item-text" ng-if="vm.allowExport && vm.model.id != null">
                    <md-button href="{{vm.model.exportUrl}}">
                        <ng-md-icon icon="launch" size="20" style="fill:#F08C38"></ng-md-icon>
                        <span style="padding-left:10px;">导出</span>
                    </md-button>
                </div>
            </div>

        </body-section>

    </card-layout>

</div>
